//案例1
// var target = { name: 'guxin', age: 25 };
// var source = { state: 'single' }
// var result = Object.assign(target, source);
// console.log(target, target == result);  //{ name: 'guxin', age: 25, state: 'single' } true
// //source上的state属性合并到了target对象上,返回新的对象就是目标对象

// var result1 = Object.assign({}, target, source);
// console.log(result1)
// //不改变原有对象的属性，可以用一个空的对象作为target对象。像下面这样：

//案例2
// var target = { name: 'guxin', age: 18 }
// var source = { state: 'signle', age: 22 }
// var result = Object.assign(target, source)
// console.log(target)  //{ name: 'guxin', age: 22, state: 'signle' }

//案例3：
var target = { name: 'guxin', age: 18 }
var source1 = { state: 'signle', age: 22 }
var source2 = { mood: 'happy', age: 25 }
var result = Object.assign(target, source1, source2)
console.log(target) // { name: 'guxin', age: 25, state: 'signle', mood: 'happy' }